﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace SuperGo.Silverlight {
	public partial class GoPanel {
		public GoPanel() {
			try {
				InitializeComponent();
				Loaded += new RoutedEventHandler(GoPanel_Loaded);
			} catch (Exception ex) {
				ControlBase.GetPage(this).ShowDialog("An Error Occurred", ex.ToString());
			}
		}

		void GoPanel_Loaded(object sender, RoutedEventArgs e) {
			// removed due to run-time error, was important in beta1
			//DataContext = this;

			foreach (FrameworkElement child in Children) {
				// this is such a hack, but I'm tired of working on the problem
				if (child.Name.StartsWith("__goPanel")) continue;
				
				child.SetValue(RowProperty, 2);
				child.SetValue(ColumnProperty, 1);
			}
		}

		private string _privateTitle;
		
		public string Title {
			get { return _privateTitle; }
			set { _privateTitle = value; _title.Text = _privateTitle; }
		}
	}
}
